import type { FaceInfo, FaceInfoType, FaceSearch, IDParams } from './faceType'
import type { BasicResp } from '~/api/core/types/types'

// 添加新的人脸信息
export function AddFaceInfo(params: FaceInfo) {
  return useHttp<BasicResp<FaceInfoType>>({
    url: '/faceinfo',
    method: 'post',
    data: { ...params },
  })
}

// 删除人脸信息
export function DeleteFaceInfo(id: number) {
  return useHttp<BasicResp<IDParams>>({
    url: `/faceinfo/${id}`,
    method: 'delete',
  })
}

// 更新人脸信息
export function UpdateFaceInfo(params: FaceInfoType) {
  return useHttp<BasicResp<FaceInfoType>>({
    url: `/faceinfo/${params.id}`,
    method: 'put',
    data: { ...params },
  })
}

// 查询
// 查询所有
export function GetAllFaceInfos() {
  return useHttp<BasicResp<FaceInfoType[]>>({
    url: '/faceinfo',
    method: 'get',
  })
}

// 查询指定ID
export function GetFaceInfo(id: number) {
  return useHttp<BasicResp<FaceInfoType>>({
    url: `/faceinfo/${id}`,
    method: 'get',
  })
}

// 静态图片搜索
export function SearchFaceImage(params: { image: string }) {
  return useHttp<BasicResp<FaceSearch[]>>({
    url: '/search',
    method: 'post',
    data: { ...params },
  })
}
